/**
 * 
 */
package com.wbl.server;


import java.net.ServerSocket;
import java.util.Date;

import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelOption;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioServerSocketChannel;

/**
 * @Description:  
 * @version: v1.0.0
 * @author: wbl
 * @date: 2020年1月13日 下午1:31:17
 */
public class ServerConnect {
	
	public static void main(String[] args) {

		System.out.println("牛牛服务器已启动");
		run();
	}
	public static void run() {
		EventLoopGroup bossGroup = new NioEventLoopGroup(4);
        EventLoopGroup workerGroup = new NioEventLoopGroup(4);
        try {
            ServerBootstrap gateServer = new ServerBootstrap();
            gateServer.group(bossGroup, workerGroup)
                    .channel(NioServerSocketChannel.class)
                    .option(ChannelOption.SO_BACKLOG, 1024)
                    .childHandler(new DivChannelInitializer());
            ChannelFuture f = gateServer.bind(8888).sync();
            f.channel().closeFuture().sync();
        } catch (InterruptedException e) {
            e.printStackTrace();
        } finally {
            /**优雅退出，释放线程池资源*/
            bossGroup.shutdownGracefully();
            workerGroup.shutdownGracefully();
        }
	}

	
	
}
